const { FusesPlugin } = require("@electron-forge/plugin-fuses");
const { FuseV1Options, FuseVersion } = require("@electron/fuses");
const path = require("path");

module.exports = {
  packagerConfig: {
    asar: true,
    name: "SM809 Gaming Mouse",
    productName: "SM809 Gaming Mouse",
    overwrite: true, // 是否覆盖已存在的打包文件
    ignore: [
      // 不需要打包的文件和文件夹的路径列表
      ".git",
      ".vscode",
      "node_modules/.cache",
      "src",
      "gmouse",
      "yjs",
      "web",
    ],
    icon: path.join(__dirname, "favicon"), // 不需要文件扩展名
  },
  rebuildConfig: {},
  makers: [
    {
      name: "@electron-forge/maker-squirrel",
      platforms: ["win32"],
      config: {
        // An URL to an ICO file to use as the application icon (displayed in Control Panel > Programs and Features).
        iconUrl: "file://" + path.join(__dirname, "favicon.ico"), // 指定安装包图标,
        // The ICO file to use as the icon for the generated Setup.exe
        setupIcon: path.join(__dirname, "favicon.ico"), // 指定 setup 图标
        authors: "Eleven",
        description: "SM809 Gaming Mouse",
      },
    },
    {
      name: "@electron-forge/maker-zip",
      platforms: ["darwin"],
    },
    {
      name: "@electron-forge/maker-deb",
      config: {
        options: {
          icon: "/favicon.ico",
        },
      },
    },
    {
      name: "@electron-forge/maker-dmg",
      config: {
        format: "ULFO",
      },
    },
    {
      name: "@electron-forge/maker-rpm",
      config: {},
    },
  ],
  plugins: [
    {
      name: "@electron-forge/plugin-auto-unpack-natives",
      config: {},
    },
    // Fuses are used to enable/disable various Electron functionality
    // at package time, before code signing the application
    new FusesPlugin({
      version: FuseVersion.V1,
      [FuseV1Options.RunAsNode]: false,
      [FuseV1Options.EnableCookieEncryption]: true,
      [FuseV1Options.EnableNodeOptionsEnvironmentVariable]: false,
      [FuseV1Options.EnableNodeCliInspectArguments]: false,
      [FuseV1Options.EnableEmbeddedAsarIntegrityValidation]: true,
      [FuseV1Options.OnlyLoadAppFromAsar]: true,
    }),
  ],
};
